package cn.edu.javaweb.userServlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.javaweb.utils.DBUtil;



@WebServlet("/HomeServlet")
public class HomeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	DBUtil db;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		db=new DBUtil(); //建创对象 搭桥配置初始化
		String sql="select * from news where roster='0'";  //写入sql语句
		System.out.println(sql);
		List list=db.getList(sql);
//		request.setAttribute("List",list);
	    request.setAttribute("List", list);//存入会话对象
		System.out.println(list);
		request.getRequestDispatcher("volunteer/user/UserHome.jsp").forward(request, response);
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}

}
